<template>
    <h1>投资信息添加页面</h1>

    <table>
        <tr>
            <td>投资总额度</td>
            <td>
                <input type="text" v-model="Invest.I_Name" >
            </td>
        </tr>

        <tr>
            <td>投资总额度</td>
            <td>
                <input type="text" v-model="Invest.I_SumMoney" >
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="提交" @click="AddInvest" />
            </td>
        </tr>

    </table>

</template>

<script setup lang="ts">

import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router = useRouter();

const Invest = ref({
    I_Name:'',
    I_SumMoney:'',
})

const AddInvest = ()=>{
    axios({
        method:'post',
        url:'http://localhost:62946/api/Invest/AddInvest',
        data:{
            I_Name:Invest.value.I_Name,
            I_SumMoney:Invest.value.I_SumMoney,
        },
    })
    .then(res=>{
        if(res.data>0){
            alert("添加成功");
            router.push('/InvestShow');
        }
        else{
            alert("添加失败");
            return;
        }
    })
    .catch(err=>{
        console.log(err);
    })
}

</script>
